fix: resolve CS1574 unresolved DatabaseFacade/ChangeTracker doc crefs in sample DbContexts (#539)#549
Merged
Conversation
… in sample DbContexts (CommunityToolkit#539) Adds the missing using Microsoft.EntityFrameworkCore.Infrastructure (and .ChangeTracking where needed) directives so XML doc <see cref=.../> tags referencing DatabaseFacade.EnsureCreated(Async) and ChangeTracker.Clear resolve correctly, matching the existing pattern in TodoApp.Avalonia. Affected sample DbContexts: - TodoApp.Uno/Database/AppDbContext.cs - TodoApp.WPF/Database/AppDbContext.cs - TodoApp.WinUI3/Database/AppDbContext.cs - TodoApp.BlazorWasm.Server/Database/TodoContext.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #539.
Several sample
DbContext/initializer classes have XML doc<see cref="..."/>tags that reference EF Core types (DatabaseFacade,ChangeTracker) which live in sub-namespaces (Microsoft.EntityFrameworkCore.Infrastructure,Microsoft.EntityFrameworkCore.ChangeTracking) not covered by the file'susing Microsoft.EntityFrameworkCore;import. The C# compiler can't resolve thecrefwithout the type in scope, producing CS1574 warnings:This only reliably surfaces on TFMs/SDKs that enable XML doc-comment analysis by default (e.g.
Microsoft.Android.Sdk, as seen in the linked CI run forTodoApp.Uno), but the underlying missing-using bug is present regardless of head, and reproduces on any TFM onceGenerateDocumentationFileis turned on.The issue reported only
TodoApp.Uno, but the same bug pattern exists inTodoApp.WPF,TodoApp.WinUI3, andTodoApp.BlazorWasm.Server—TodoApp.Avaloniaalready has the correct import, which is the pattern this PR applies elsewhere.Changes
Added the missing
usingdirective(s) so the doccrefs resolve, matching the existing correct pattern inTodoApp.Avalonia/Database/DbContextInitializer.cs:samples/todoapp/TodoApp.Uno/TodoApp.Uno/Database/AppDbContext.csMicrosoft.EntityFrameworkCore.InfrastructureDatabaseFacade.EnsureCreatedsamples/todoapp/TodoApp.WPF/Database/AppDbContext.csMicrosoft.EntityFrameworkCore.InfrastructureDatabaseFacade.EnsureCreatedsamples/todoapp/TodoApp.WinUI3/Database/AppDbContext.csMicrosoft.EntityFrameworkCore.InfrastructureDatabaseFacade.EnsureCreatedsamples/todoapp-blazor-wasm/TodoApp.BlazorWasm.Server/Database/TodoContext.csMicrosoft.EntityFrameworkCore.ChangeTracking,Microsoft.EntityFrameworkCore.InfrastructureDatabaseFacade.EnsureCreatedAsync,ChangeTracker.ClearNo behavior changes — doc-comment-only fix.
Verification
TodoApp.Unochange and buildingnet10.0-desktopwith-p:GenerateDocumentationFile=true; re-applying the fix removes the warning (0 errors, 0 CS1574).TodoApp.BlazorWasm.Server(net10.0) with-p:GenerateDocumentationFile=true; confirmedDatabaseFacade.EnsureCreatedAsyncandChangeTracker.Clearno longer emit CS1574.TodoApp.WPF/TodoApp.WinUI3are Windows-only TFMs and could not be built in my (macOS) environment — same limitation noted by @nightcityblade in the issue thread. The fix is a mechanical one-line addition identical to the verified Uno/BlazorWasm fixes and the existing working Avalonia precedent.dotnet build Datasync.Toolkit.sln -c Release: 0 warnings, 0 errors (core solution doesn't reference sample projects — confirms this change is fully isolated tosamples/).dotnet test Datasync.Toolkit.sln -c Release --no-build:CommunityToolkit.Datasync.Client.Test1432/1432 passed.CommunityToolkit.Datasync.Server.Testfailures are pre-existingDockerUnavailableException(no local Docker daemon in this environment) per the repo's TestContainers-based test setup, unrelated to this change.Follow-ups (filed separately, not in this PR)
TodoApp.BlazorWasm.Client(ValidationException,ConcurrencyException, generic-method overload crefs likeAddAsync(T)) — different root cause (ambiguous/overload cref resolution).TodoContext.cs's<see cref="EntityFrameworkQueryableExtensions.AnyAsync{TSource}(IQueryable{TSource})"/>still doesn't resolve because the cref's parameter list omits theCancellationTokenoverload parameter.